package io;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class TestFileCopy2 {
    public static void main(String[] args) {
        try (FileReader reader = new FileReader("d:/test.txt");
             FileWriter writer = new FileWriter("d:/test2.txt")){
            char[] chars = new char[16];
            int tmp;
            while((tmp = reader.read(chars)) != -1){
                writer.write(new String(chars, 0, tmp));
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
